import Vue from 'vue';
import axios from 'axios';
import {setCookie,removeCookie,getCookie } from '@/api/login'
axios.defaults.withCredentials=true;//统一携带凭证，用来反向跨域
axios.interceptors.response.use(function (response) {
    // 做一些事情，给config==响应体 ,附加一些东西
 
     if(response.data.code==4002){
          
          var storage = window.localStorage;
          storage.clear()
          removeCookie('sunzheng');
          removeCookie('sunzhengtype');
          removeCookie('wangyiaccid');
          removeCookie('wangyitoken');
          setCookie('islogin',false);
          alert('登录超时，请重新登录')
          window.location.href="http://cn.zoomoffices.com"
     }
   return response;
 }, function (error) {
   // Do something with response error
   return Promise.reject(error);
 });
window.axios=axios;
Vue.prototype.$axios=axios;

export default axios;